package com.hongyuan.coach.ui.course.activity;

import android.os.Bundle;

import androidx.lifecycle.ViewModelProviders;
import com.hongyuan.coach.R;
import com.hongyuan.coach.base.AppViewModelFactory;
import com.hongyuan.coach.base.CustomActivity;
import com.hongyuan.coach.data.Constants;
import com.hongyuan.coach.databinding.ActivityCourseListBinding;
import com.hongyuan.coach.ui.course.view_mode.CourseListViewMode;

import me.tatarka.bindingcollectionadapter2.BR;

public class CourseListActivity extends CustomActivity<ActivityCourseListBinding, CourseListViewMode> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_course_list;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public CourseListViewMode initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(CourseListViewMode.class);
    }

    @Override
    public void initView() {
        super.initView();

        setOnRefresh(binding.refresh,REFRESH_0X3);
        setEnableLoadMore(Constants.GET_COURSE_PRIVITE_LIST);
        setEnableRefresh(Constants.GET_COURSE_PRIVITE_LIST);

        binding.comBack.setOnClickListener(view -> finish());
    }

    @Override
    public void initData() {
        super.initData();

        viewModel.setParams("cp_mid",viewModel.userToken.getM_id())
                .requestData(Constants.GET_COURSE_PRIVITE_LIST);
    }

}
